package com.shuoyue.ycgk.ui.course.contract;

import com.shuoyue.ycgk.base.BaseModel;
import com.shuoyue.ycgk.base.BasePresenter;
import com.shuoyue.ycgk.base.BaseResult;
import com.shuoyue.ycgk.base.BaseView;
import com.shuoyue.ycgk.base.ListWithPage;
import com.shuoyue.ycgk.entity.Course;
import com.shuoyue.ycgk.entity.CourseInfo;
import com.shuoyue.ycgk.entity.TimerTable;
import com.shuoyue.ycgk.net.RetrofitClient;
import com.shuoyue.ycgk.net.base.ApiSubscriber;
import com.shuoyue.ycgk.net.gsondefaultadapter.Optional;

import io.reactivex.Observable;

public interface SpecialContract {
    interface View extends BaseView {

        void registSuc(String phone);
    }


    class Presenter extends BasePresenter<View> {
        Model model = new Model();

        public void registSpecialCourse(String name, String phone, String time, String typeStr) {
            apply(model.registSpecialCourse(name, phone, time, typeStr))
                    .subscribe(new ApiSubscriber<Optional<String>>(mView, this) {
                        @Override
                        public void onNext(Optional<String> listWithPageOptional) {
                            super.onNext(listWithPageOptional);
                            mView.registSuc(phone);
                        }
                    });
        }
    }

    class Model extends BaseModel {
        Observable<BaseResult<String>> registSpecialCourse(String name, String phone, String time, String typeStr) {
            return RetrofitClient.getInstance().getApi().registSpecialCourse(name, phone, time, typeStr);
        }
    }
}
